<#import "../../../common/layout.ftl" as l>


<@l.content>

<script>
    var crud = {
        read: "/manage/ship/user/detail",
        update: '/manage/ship/user/update',
        del: "/manage/ship/user/delete"
    };

    var model = [
        {name : 'id',type : 'hidden',text : '用户编号',allowBlank : true,primaryKey : true},
        {name : 'userType',type : 'select',text : '用户类型',allowBlank : false,primaryKey : false,optionList : [
            {
                displayField : '导航用户',
                valueField : '1'
            },{
                displayField : '监控用户',
                valueField : '2'
            }
        ]},
        {name : 'shipid',type : 'select',text : '船舶',allowBlank : true,primaryKey : false,options : {
            url : "/manage/ship/ajax/list",
            displayField : "shipName",
            valueField : "shipid"
        }},
        {name : 'loginName',type : 'text',text : '账号',allowBlank : false,primaryKey : false},
        {name : 'password',type : 'password',text : '密码',allowBlank : false,primaryKey : false},
        {name : 'monitorShips',type : 'select',multiple:true,text : '监控船舶',allowBlank : true,primaryKey : false,options : {
            url : "/manage/ship/ajax/list",
            displayField : "shipName",
            valueField : "shipid"
        }},
        {name : 'iemi',type : 'text',text : 'IMEI',allowBlank : false,primaryKey : false},
//        {name : 'ship_name',type : 'hidden',text : '船名',allowBlank : false,primaryKey : false},
        {name : 'companyId',type : 'hidden',text : '公司账号',allowBlank : true,primaryKey : false},
        {name : 'status',type : 'hidden',text : '状态',allowBlank : true,primaryKey : false},
        {name : 'shipRegno',type : 'text',text : '船舶注册号',allowBlank : true,primaryKey : false},
//        {name : 'tel',type : 'number',text : '手机号码',allowBlank : false,primaryKey : false},
    ];
</script>


<form id="pagination-form" method="post">
    <input type="hidden" name="shipid" value="<#if param.shipid??>${param.shipid}<#else></#if>">
    <input type="hidden" name="page" value="${pageInfo.pageNum}">
    <input type="hidden" name="limit" value="${pageInfo.pageSize}">
    <input type="hidden" name="totalPage" value="${pageInfo.pages}">
    <div class="ibox">
        <div class="ibox-title">
            <h5><#if Session['currentMenu']??>${Session['currentMenu'].name}<#else></#if></h5>

            <div class="ibox-tools">
                <a href="#" id="pagination-add">
                    <i class="fa fa-plus"></i>
                    添加
                </a>
                <a id="pagination-edit" href="#">
                    <i class="fa fa-edit"></i>
                    编辑
                </a>

                <a id="pagination-delete" href="#">
                    <i class="fa fa-trash"></i>
                    删除
                </a>

            </div>
        </div>
        <div class="ibox-content">
            <div class="input-group search-content">
                <input type="text" name="loginName" value="<#if param.loginName??>${param.loginName}<#else></#if>" class="form-control" placeholder="输入账号名查询"> <span class="input-group-btn">
                <input type="submit" class="btn btn-primary" value="搜索">
            </span></div>
            <div>
                <div class="table-responsive">
                    <table class="table table-striped table-hover dataTables-example" >
                        <thead>
                        <tr>
                            <th>&nbsp;</th>
                            <#--<th>用户编号</th>-->
                            <th>账号</th>
                            <th>用户类型</th>
                            <th>IMEI</th>
                            <th>船名</th>
                            <#--<th>公司账号</th>-->
                            <#--<th>状态</th>-->
                            <th>船舶注册号</th>
                            <#--<th>手机号码</th>-->
                        </tr>
                        </thead>

                        <tbody>
                            <#list pageInfo.list as report>
                            <tr>
                                <td><input type="checkbox" class="i-checks" value="<#if report.id??>${report.id}<#else></#if>"></td>
                                <#--<td><#if report.id??>${report.id}<#else></#if></td>-->
                                <td><a href="#" onclick="pagination.editItem('<#if report.id??>${report.id}<#else></#if>')"><#if report.loginName??>${report.loginName}<#else></#if></a></td>
                                <td><#if report.userType??><#if report.userType == "1">导航用户<#else>监控用户</#if><#else></#if></td>
                                <td><#if report.iemi??>${report.iemi}<#else></#if></td>
                                <td><#if report.ship??><#if report.ship.shipName??>${report.ship.shipName}<#else></#if><#else></#if></td>
                                <#--<td><#if report.companyId??>${report.companyId}<#else></#if></td>-->
                                <#--<td><#if report.status??>${report.status}<#else></#if></td>-->
                                <td><#if report.shipRegno??>${report.shipRegno}<#else></#if></td>
                                <#--<td><#if report.tel??>${report.tel}<#else></#if></td>-->
                            </tr>
                            </#list>
                        </tbody>


                    </table>
                </div>
                <div class="pagination-content">
                    <div id="pagination" class="pagination">
                    </div>
                </div>
            </div>
        </div>

    </div>
</form>


</@l.content>

<script src="/pagination/js/pagination.js"></script>

<script>
    function changeForm(userType) {
        var form = pagination.getForm();
        var val = userType.val();
        var shipid = form.find("div[name=shipid_div]");
        var monitorShips = form.find("div[name=monitorShips_div]");
        var shipRegno = form.find("div[name=shipRegno_div]");
        if(val == "1"){  //导航用户
            monitorShips.hide();
            shipid.show();
            shipRegno.show();
        }else if(val == "2"){  //监控用户
            monitorShips.show();
            shipid.hide();
            shipRegno.hide();
        }
    }

    function initFormCallback() {
        var form = pagination.getForm();
        var userType = form.find("[name=userType]");
        changeForm(userType);
        userType.change(function () {
            changeForm($(this))
        })
    }
</script>
